package com.hnas.trade.dto.intf;

import java.util.ArrayList;
import java.util.List;

import com.hnas.common.util.CommonUtils;
import com.hnas.oracle.dto.DTOMrchDetail;
import com.hnas.trade.domain.DetailType;
import com.hnas.trade.dto.DTOCouponDetail;
import com.hnas.trade.dto.DTOOrder;
import com.hnas.trade.dto.DTOOrderDetail;
import com.hnas.trade.dto.DTOVipProductDetail;

public class BestSolutionBean {
	private DTOMrchDetail mrch;
	private DTOVipProductDetail vip;
	private List<DTOCouponDetail> coupons;
	private Long realPay;
	
	public DTOMrchDetail getMrch() {
		return mrch;
	}

	public void setMrch(DTOMrchDetail mrch) {
		this.mrch = mrch;
	}

	public DTOVipProductDetail getVip() {
		return vip;
	}

	public void setVip(DTOVipProductDetail vip) {
		this.vip = vip;
	}

	public List<DTOCouponDetail> getCoupons() {
		return coupons;
	}

	public void setCoupons(List<DTOCouponDetail> coupons) {
		this.coupons = coupons;
	}

	public Long getRealPay() {
		return realPay;
	}

	public void setRealPay(Long realPay) {
		this.realPay = realPay;
	}
	
	public DTOOrderDetail getMrchOrderDetail(DTOOrder orderDto) {
		DTOOrderDetail mrchDetail = null;
		if(mrch != null){
			mrchDetail = new DTOOrderDetail();
			mrchDetail.setId(CommonUtils.getUUID());
			mrchDetail.setType(DetailType.MrchDiscount.getKey());
			mrchDetail.setRelateId(mrch.getMrchId());
			mrchDetail.setOrderNo(orderDto.getOrderNo());
			mrchDetail.setDiscountAmount(mrch.getDiscountAmount());
			mrchDetail.setDiscountValue(mrch.getDiscountValue());
			mrchDetail.setProductName("商户打折"+mrch.getDiscountValue());
			mrchDetail.setIsDeleted(false);
		}
		return mrchDetail;
	}

	public DTOOrderDetail getVipOrderDetail(DTOOrder orderDto) {
		DTOOrderDetail vipDetail = null;
		if(vip != null){
			vipDetail = new DTOOrderDetail();
			vipDetail.setId(CommonUtils.getUUID());
			vipDetail.setType(DetailType.VIP.getKey());
			vipDetail.setRelateId(vip.getProductId());
			vipDetail.setOrderNo(orderDto.getOrderNo());
			vipDetail.setDiscountAmount(vip.getDiscountAmount());
			vipDetail.setDiscountType(vip.getDiscountType());
			vipDetail.setDiscountValue(vip.getDiscountValue());
			vipDetail.setPeriodType(vip.getPeriodType());
			vipDetail.setPeriodValue(vip.getPeriodValue());
			vipDetail.setProductName(vip.getProductName());
			vipDetail.setProductType(vip.getProductType());
			vipDetail.setProductPrice(vip.getProductPrice());
			vipDetail.setIsDeleted(false);
		}
		return vipDetail;
	}
	
	public List<DTOOrderDetail> getCouponOrderList(DTOOrder orderDto) {
		List<DTOOrderDetail> list = new ArrayList<DTOOrderDetail>();
		if(null!=coupons&&coupons.size()>0){
			for(DTOCouponDetail coupon : coupons){
				DTOOrderDetail couponDetail = new DTOOrderDetail();
				couponDetail.setId(CommonUtils.getUUID());
				couponDetail.setType(DetailType.COUPON.getKey());
				couponDetail.setRelateId(coupon.getCouponId());
				couponDetail.setOrderNo(orderDto.getOrderNo());
				couponDetail.setDiscountAmount(coupon.getDiscountAmount());
				couponDetail.setDiscountType(coupon.getDiscountType());
				couponDetail.setDiscountValue(coupon.getDiscountValue());
				couponDetail.setCouponTypeName(coupon.getCouponTypeName());
				couponDetail.setCreateType(coupon.getCreateType());
				couponDetail.setDelayTime(coupon.getDelayTime());
				couponDetail.setDiscountAmount(coupon.getDiscountValue());
				couponDetail.setValidBeginTime(coupon.getValidBeginTime());
				couponDetail.setValidEndTime(coupon.getValidEndTime());
				couponDetail.setIsDeleted(false);
				couponDetail.setProductName(coupon.getCouponTypeName());
				list.add(couponDetail);
			}
		}
		return list;
	}

}
